﻿using Clancy.Interfaces;
using System;
using System.Linq;
using System.Reactive.Subjects;

namespace Clancy.Bl
{
    internal class SelectionManager : ISelectionManager
    {
        private readonly BehaviorSubject<ISelectable> m_CurrentSelection = new BehaviorSubject<ISelectable>(null);

        public IObservable<ISelectable> CurrentSelection
        {
            get { return m_CurrentSelection; }
        }

        public ISelectable SelectedObject { get; private set; }

        public void ClearSelection()
        {
            m_CurrentSelection.OnNext(null);
        }

        public void SetSelection(ISelectable selectable)
        {
            m_CurrentSelection.OnNext(selectable);
        }
    }
}